﻿using Silverlight.Training.Server.Common.Feedbacks;

namespace Silverlight.Training.Server.Common
{
    public interface IDataAccessObject<T>
    {
        /// <summary>
        /// This method aims to get all records of a table from database
        /// </summary>
        /// <returns>
        /// An Feedback object contains all those records
        /// </returns>
        CollectionFeedback<T> GetCollection();

        /// <summary>
        /// This method aims to get detailed information of an department based on its ID.
        /// </summary>
        /// <param name="deptID">
        /// The ID of the desired department
        /// </param>
        /// <returns>
        /// A Feedback object containing a detailed object
        /// </returns>
        SingleFeedback<T> GetSingle(int objectID);

        /// <summary>
        /// This method aims to insert a new object into database
        /// </summary>
        /// <param name="data">
        /// The object to be inserted
        /// </param>
        /// <returns>
        /// A Feedback object containing information about 
        ///    - inserting result and 
        ///    - the ID of new object if success or -1
        /// </returns>
        SingleFeedback<int> Insert(T data);

        /// <summary>
        /// This method aims to update an existing record in database
        /// </summary>
        /// <param name="data">
        /// The object to be updated
        /// </param>
        /// <returns>
        /// A Feedback object containing information about updating result
        /// </returns>
        Feedback Update(T data);

        /// <summary>
        /// This method aims to delete an existing record in database
        /// </summary>
        /// <param name="data">
        /// The object to be deleted
        /// </param>
        /// <returns>
        /// A Feedback object containing information about deleting result
        /// </returns>
        Feedback Delete(T data);

        /// <summary>
        /// This method aims to find out specific record(s) in the database based on the input criteria.
        /// </summary>
        /// <param name="criteria">
        /// The object contains the searching criteria.
        /// </param>
        /// <returns>
        /// A Feedback object containing information about deleting result
        /// </returns>
        CollectionFeedback<T> Search<TCriteria>(TCriteria criteria);
    }
}
